<%-- 
    Document   : LoginProcess.jsp
    Created on : Jun 13, 2013, 7:05:17 PM
    Author     : Acer
--%>

<%@page import="java.sql.*" 
        errorPage="/myError.jsp"%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Login Process</title>
    </head>
    <body>
        <%
                    Connection con = null;
                    String uname = request.getParameter("uname");
                    String pass = request.getParameter("pass");
                    try {
                        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                        con = DriverManager.getConnection("jdbc:odbc:ClassAccessDatabase", "admin", "1234");

                        Statement ps = con.createStatement();
                        ResultSet rs = ps.executeQuery("SELECT * FROM usuarios WHERE usuario ='" + uname + "' AND password ='" + pass + "'");
                        if (!rs.next()) {
                            Integer erro = new Integer(uname);
        %>
        User details given for user name: <%=request.getParameter("uname")%> and password: <%=request.getParameter("pass")%>
        are not valid<br/> Try again <%@include file="LoginError.jsp"%>
        <%
                            return;
                        }
                    } finally {
                        try {
                            con.close();
                        } catch (Exception ex) {
                        }
                    }
        %>
        This is a Home Page<br/>
        Welcome, <%=uname%>
    </body>
</html>
